<?php
abstract class Core_Db_Adapter_Abstract{

    protected $_conexion = null;
    protected $_limit = "";
    protected $_where = "";
    protected $_notWhere = "";
    protected $_order = "";
    protected $_table = "";
    protected $_config = array();
    protected $_isConectado = false;

    public function  __construct(array $config)
    {
        $this->_revisarConfig($config);
        $this->_config = $config;
    }

    protected function _revisarConfig(array $config)
    {
        if (!array_key_exists("host", $config))
        {
            throw new Exception("No existe la direccion del host en la configuracion.", 0);
        }
        
        if (!array_key_exists("dbname", $config))
        {
            throw new Exception("No existe el nombre de bd en la configuracion.", 0);
        }

        if (!array_key_exists("clave", $config))
        {
            throw new Exception("No existe la clave en la configuracion.", 0);
        }

        if (!array_key_exists("usuario", $config))
        {
            throw new Exception("No existe el usuario en la configuracion.", 0);
        }
    }

    abstract protected function _conectar();
    abstract protected function _desconectar();
    
    public function isConectado()
    {
        return $this->_isConectado;
    }
    
    abstract public function setLimit($limit);
    abstract public function setWhere($cols, $vals);
    abstract public function setOrder($orderBy,$order=null);

    public function setTable($tabla)
    {
        if (is_string($tabla))
        {
            $this->_table = $tabla;
        }else{
            throw new Exception("Nombre de tabla no es un String.", 0);
        }
    }

    abstract public function select($cols=null);
    abstract public function insert($cols,$vals);
    abstract public function delete();
    abstract public function update($cols,$vals);

}
//Archivo: Abstract.php
//Ubicacion: Core/Db/Adapter/Abstract.php
